<?php

class Service_sql extends MY_Service
{
    public function __construct()
    {
        parent::__construct();
        $this->load->model('Model_common');
    }

    public function exec($id)
    {
        $this->Model_common->setTable('sql');
        $sqlInfo = $this->Model_common->get($id);
        $sql = $sqlInfo['sql'];
        $params = explode(',', $sqlInfo['params']);
        if (!empty($sql)) {
            if ($sqlInfo['db']) {
                $db = $this->load->database($sqlInfo['db'], true);
                $this->Model_common->setDb($db);
            }
            $res = $this->Model_common->queryForUpdate($sql, $params);
        }
        return $res;
    }

}
